﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Libs.Content;
using Libs.Utils;
using System.Web.Script.Serialization;

public partial class Controls_Home_ShortNews : System.Web.UI.UserControl
{
    public int CateID { get; set; }
    public int RowNumber { get; set; }
    public int CharLength { get; set; }

    protected string JsonShortNews = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        //NewsWeb _NewsWeb = new NewsWeb();
        //List<NewsWeb> list;

        //list = _NewsWeb.GetList(CateID, 0, RowNumber);
        //JavaScriptSerializer serializer = new JavaScriptSerializer();
        //JsonShortNews = serializer.Serialize(list);

        NewsWeb _NewsWeb = new NewsWeb();
        List<NewsWeb> list;

        list = _NewsWeb.GetList(23, 0, 1);
        _NewsWeb = list[0];

        NewsSub _NewsSub = new NewsSub();
        List<NewsSub> list1;
        list1 = _NewsSub.GetList(_NewsWeb.NewsID);
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        JsonShortNews = serializer.Serialize(list1);

        //_NewsWeb = list[0];
        //if (_NewsWeb.SubLead.Length > CharLenght)
        //{
        //    _NewsWeb.SubLead = _NewsWeb.SubLead.Substring(0, CharLenght) + "...";
        //}
        //if (string.IsNullOrEmpty(_NewsWeb.ImageUrl))
        //{
        //    ltrNews.Text = Resources.Template.HomeCate;
        //}
        //else
        //{
        //    ltrNews.Text = Resources.Template.HomeCateImg;
        //    ltrNews.Text = ltrNews.Text.Replace("$ImageUrl$", AppUtils.ImageUrl(_NewsWeb.ImageUrl, "129", "80"));
        //}
        //ltrNews.Text = ltrNews.Text.Replace("$Link$", _NewsWeb.Url);
        //ltrNews.Text = ltrNews.Text.Replace("$Title$", _NewsWeb.Title);
        //ltrNews.Text = ltrNews.Text.Replace("$Lead$", _NewsWeb.SubLead);

        //list.RemoveAt(0);
        //rptList.DataSource = list;
        //rptList.DataBind();
    }
}